prefix :: String -> String -> String -> String
prefix xs ys zs     
    | null xs || null ys = r
    | otherwise = if x == y then prefix a b (x:zs) else r
    where r = reverse zs
          x = head xs
          y = head ys
          a = tail xs
          b = tail ys          
            
prefixCompression :: String -> String -> [[String]]
prefixCompression xs ys = [[show lp, p], [show lx, x], [show ly, y]]
    where p = prefix xs ys ""
          lp = length p
          x = drop lp xs
          y = drop lp ys
          lx = length x
          ly = length y
    
main = do
    xs <- getLine
    ys <- getLine
    putStr $ unlines $ map unwords $ prefixCompression xs ys